/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.restaurant.entities;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author Dexter
 */
@Entity
@Table(name = "ProductsInOrders")
@NamedQueries({
    @NamedQuery(name = "ProductsInOrders.findAll", query = "SELECT p FROM ProductsInOrders p"),
    @NamedQuery(name = "ProductsInOrders.findByProductInOrderId", query = "SELECT p FROM ProductsInOrders p WHERE p.productInOrderId = :productInOrderId")})
public class ProductsInOrders implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "ProductInOrderId")
    private Long productInOrderId;
    @JoinColumn(name = "ProductId", referencedColumnName = "ProductId")
    @ManyToOne(fetch = FetchType.LAZY)
    private Products productId;
    @JoinColumn(name = "OrderId", referencedColumnName = "OrderId")
    @ManyToOne(fetch = FetchType.LAZY)
    private Orders orderId;
    
    public ProductsInOrders() {
    }

    public ProductsInOrders(Long productInOrderId) {
        this.productInOrderId = productInOrderId;
    }

    public Long getProductInOrderId() {
        return productInOrderId;
    }

    public void setProductInOrderId(Long productInOrderId) {
        this.productInOrderId = productInOrderId;
    }

    public Products getProductId() {
        return productId;
    }

    public void setProductId(Products productId) {
        this.productId = productId;
    }

    public Orders getOrderId() {
        return orderId;
    }

    public void setOrderId(Orders orderId) {
        this.orderId = orderId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (productInOrderId != null ? productInOrderId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ProductsInOrders)) {
            return false;
        }
        ProductsInOrders other = (ProductsInOrders) object;
        if ((this.productInOrderId == null && other.productInOrderId != null) || (this.productInOrderId != null && !this.productInOrderId.equals(other.productInOrderId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.restaurant.entities.ProductsInOrders[ productInOrderId=" + productInOrderId + " ]";
    }
    
}
